//
//  MCSwitchBarView.swift
//  StoreManage
//
//  Created by MC on 2018/9/11.
//  Copyright © 2018年 MC. All rights reserved.
//

import UIKit

/**
 * 功能说明
 * 用来做有一个标题和开关的长条。
 * 样式 ：
 *
 *  leftLabel的内容                  rightSwitch的内容
 *  ——————————————————————————————————————————————
 */

class MCSwitchBarView: UIView {
    
    override init(frame: CGRect) {
        super.init(frame: frame)
        
        self.addSubview(leftLabel)
        self.addSubview(rightSwitch)
        self.addSubview(lineView)
    }
    
    override func layoutSubviews() {
        super.layoutSubviews()
        
        leftLabel.snp.remakeConstraints { (make) ->Void in
            make.centerY.equalTo(self)
            make.left.equalTo(0)
        }
        
        rightSwitch.snp.remakeConstraints { (make) ->Void in
            make.centerY.equalTo(self)
            make.right.equalTo(0)
        }
        
        lineView.snp.remakeConstraints { (make) ->Void in
            make.height.equalTo(1)
            make.left.right.bottom.equalTo(0)
        }
    }
    
    required init?(coder aDecoder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    
    
    public lazy var leftLabel: MCLabel = {
        let label = MCLabel()
        label.text = "左侧"
        return label
    }()
    
    
    public lazy var rightSwitch: UISwitch = {
        let sw = UISwitch()
        sw.onTintColor = UIColor.MCAssist_C
        sw.transform = CGAffineTransform(scaleX: 0.8, y: 0.8)
        return sw
    }()
    
    lazy var lineView: UIView = {
        let view = UIView()
        view.backgroundColor = UIColor.MCGray_light
        return view
    }()
}
